openerp.dftg_product_card = function (instance) {
    var QWeb = instance.web.qweb,
        _t = instance.web._t;

    instance.web.dftg_product_card = instance.web.dftg_product_card || {};

    $(function () {
        instance.web.views.add('graph_view_card_delivery_stat', 'instance.web.dftg_product_card.DayStatGraph');
        instance.web.dftg_product_card.DayStatGraph = instance.web_graph.GraphView.extend({
            init: function () {
                var self = this;
                this._super.apply(this, arguments);
                this.on('list_view_loaded', this, function () {

                });
                //统计图表上方添加按钮
                if (self.__parentedParent.$el.find('.oe_product_card_today_stat').length == 0) {
                    var button1 = $("<button type='button' class='oe_button oe_product_card_today_stat'>取得最新提货库存数据</button>")
                        .click(this.proxy('product_card_refresh_stat_action'));
                    self.__parentedParent.$el.find('.oe_view_manager_buttons').append(button1);
                }
            },
            product_card_refresh_stat_action: function () {
                var self = this;
                this.model.call('refresh_new', []).then(function () {
                    self.graph_widget.pivot.update_data().then(self.graph_widget.proxy('display_data'));
                })
            }
        });
    })
};

function query_express_detail(button){
    $(button).attr('disabled',"true");
    $parent_div = $('#express-delivery-detail');
    $parent_div.html('<img src="/web/static/src/img/throbber.gif" width="16" height="16"/>');
    var shipping_type = $parent_div.attr('data-shipping-type');
    var shipping_code = $parent_div.attr('data-shipping-code');
    $parent_div.load('/card/exchange/express-delivery-detail?shipping_type='
        + shipping_type + '&shipping_code=' + shipping_code, {}, function(){
        //$(button).removeAttr("disabled");
    });
}
